<!--
 * @Author: xuzehan 123@qq.com
 * @Date: 2023-06-14 09:34:54
 * @LastEditors: xuzehan 123@qq.com
 * @LastEditTime: 2023-06-20 11:49:22
 * @FilePath: \nms-vue\src\views\taskManagement\modules\confidModal.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <a-modal
      :title="title"
      :visible="visible"
      :confirm-loading="confirmLoading"
      @ok="handleOk"
      width="850px"
      @cancel="handleCancel"
    >
      <div v-if="type == 'ball'">
        <h4>星弹上行链路工作参数</h4>
        <a-table :columns="columns" :data-source="data"> </a-table>
      </div>
      <div v-if="type == 'car'">
        <h4>星指上/下行链路工作参数</h4>
        <a-table :columns="columnsCar" :data-source="dataCar"> </a-table>
      </div>
    </a-modal>
  </div>
</template>
<script>
const columns = [
  {
    title: '名称',
    dataIndex: 'name',
    key: 'name',
    // slots: { title: 'customTitle' },
    // scopedSlots: { customRender: 'name' },
  },
  {
    title: '信道号',
    dataIndex: 'CHANNEL',
    key: 'CHANNEL',
  },
  {
    title: '可控接收机本振频点切换指令',
    dataIndex: 'switchInstruction',
    key: 'switchInstruction',
  },
  {
    title: '滤波器选通指令',
    key: 'waveFilter',
    dataIndex: 'waveFilter',
    // scopedSlots: { customRender: 'waveFilter' },
  },
  {
    title: '数字滤波器选通指令',
    key: 'digitalFilter',
    dataIndex: 'digitalFilter',
    // scopedSlots: { customRender: 'digitalFilter' },
  },
]
const data = [
  {
    key: '1',
    name: '指控车1',
    CHANNEL: '1,2,3,4,5,6',
    switchInstruction: 10,
    waveFilter: 5,
    digitalFilter: 9,
  },
  {
    key: '2',
    name: '指控车2',
    CHANNEL: '7,8,9,10,11,12',
    switchInstruction: '5',
    waveFilter: 8,
    digitalFilter: 11,
  },
  {
    key: '3',
    name: '指控车3',
    CHANNEL: '13,14,15,16,17,18',
    switchInstruction: 6,
    waveFilter: 4,
    digitalFilter: 15,
  },
]
const columnsCar = [
  {
    title: '名称',
    dataIndex: 'name',
    key: 'name', // slots: { title: 'customTitle' }, // scopedSlots: { customRender: 'name' },
  },
  {
    title: '指控车同步时隙起跳数',
    dataIndex: 'jumpNumber',
    key: 'jumpNumber ',
  },
  {
    title: '星指上行链路工作参数',
    dataIndex: 'uplinkParameters',
    key: 'uplinkParameters',
  },
  {
    title: '星指下行链路工作参数',
    key: 'downlinkParameters',
    dataIndex: 'downlinkParameters', // scopedSlots: { customRender: 'downlinkParameters' },
  },
  {
    title: '指控车时隙资源',
    key: 'slotResources',
    dataIndex: 'slotResources', // scopedSlots: { customRender: 'slotResources' },
  },
]
const dataCar = [
  {
    key: '1',
    name: '指控车1',
    jumpNumber: '1,2,3,4,5,6',
    uplinkParameters: 10,
    downlinkParameters: 5,
    slotResources: 9,
  },
  {
    key: '2',
    name: '指控车2',
    jumpNumber: '7,8,9,10,11,12',
    uplinkParameters: '5',
    downlinkParameters: 8,
    slotResources: 11,
  },
  {
    key: '3',
    name: '指控车3',
    jumpNumber: '13,14,15,16,17,18',
    uplinkParameters: 6,
    downlinkParameters: 4,
    slotResources: 15,
  },
]

export default {
  data() {
    return {
      ModalText: 'Content of the modal',
      visible: false,
      confirmLoading: false,
      dataCar,
      columnsCar,
      data,
      columns,
      type: 'ball',
      title: '',
    }
  },
  wathc: {
    type(val) {
      if (val == 'ball') {
        this.title = '导弹资源分配详情'
      } else {
        this.title = '指控车资源分配详情'
      }
    },
  },
  methods: {
    showModal(record, type) {
      this.visible = true
      this.type = type
      if (type == 'ball') {
        this.title = '导弹资源分配详情'
      } else {
        this.title = '指控车资源分配详情'
      }
    },
    handleOk(e) {
      this.ModalText = 'The modal will be closed after two seconds'
      this.confirmLoading = true
      setTimeout(() => {
        this.visible = false
        this.confirmLoading = false
      }, 2000)
    },
    handleCancel(e) {
      console.log('Clicked cancel button')
      this.visible = false
    },
  },
}
</script>
